<template>
    <div style="margin-top: 2%; margin-left: 5%; margin-right: 5%">
        <Row :gutter="10">
            <Col :span="4">
                标题
            </Col>
            <Col :span="4">
                时间
            </Col>
            <Col :span="4">
                阅读量
            </Col>
            <Col :span="4">
                点赞
            </Col>
            <Col :span="4">
                状态
            </Col>
            <Col :span="4">

            </Col>
        </Row>
        <Divider></Divider>
        <Row v-for="i in data" :key="i.id" style="font-weight: bold; font-size: large" :gutter="10">
            <Col :span="4">
                {{i.title}}
            </Col>
            <Col :span="4">
                {{i.time}}
            </Col>
            <Col :span="4">
                {{i.view}}
            </Col>
            <Col :span="4">
                {{i.like}}
            </Col>
            <Col :span="4" v-text="i.pass?'通过':'未通过'">
            </Col>
            <Col :span="4" style="padding-bottom: 5px">
                <Button type="info" @click="$router.push('/do/changeA?id='+i.id)">修改</Button>
                <Divider type="vertical"/>
                <Button type="error" @click="del(i.id)">删除</Button>
            </Col>
            <Divider></Divider>
        </Row>
        <center v-if="data == ''">
            <br/>
            <h1>这里空空如也！
                去 <a href="/do/post" style="text-decoration: none">投稿</a> 吧
            </h1>
            <br/>
            <br/>
            <br/>
            <br/>
        </center>
    </div>
</template>

<script>
    export default {
        name: "Arts",
        created() {
            const t = this;
            axios.get('/getUser').then(function (resp) {
                axios.get('/getArticleByAuthor/'+resp.data.id).then(function (resp1) {
                    t.data = resp1.data;
                    // console.log(t.data)
                })
            })
        },
        data(){
            return{
                data: '',
            }
        },
        methods:{
            del(id){
                const t = this;
                axios.delete('/delete/'+id).then(function (resp) {
                    t.$Message.info('已删除');
                    setTimeout('location.reload()',200);
                })
            },

        }
    }
</script>

<style scoped>

</style>